<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<!--/meta 作为公共模版分离出去-->
<title>添加代金券</title>
</head>
<body ng-controller="main">
<article class="page-container">
	<form action="<?php url('voucher/voucherAdd')?>" method="post" class="form form-horizontal" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>发布平台：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <select class="select" name="is_platform" id="is_platform" size="1">
                    <option value="0">商家券</option>
                    <option value="1">平台券</option>
                </select>
            </div>
        </div>
        <div class="row cl" id="business">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商家：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <select class="select" name="bid" id="bid" size="1">
                    <option value="">请选择商家</option>
                    <?php foreach($business as $v):?>
                    <option value="<?php echo $v['id']?>"><?php echo $v['name']?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>类型：</label>
			<div class="formControls col-xs-8 col-sm-10">
				<select class="select" name="type_id" id="type_id" size="1">
					<?php foreach($type as $v):?>
					<option value="<?php echo $v['id']?>"><?php echo $v['name']?></option>
					<?php endforeach; ?>
				</select>
			</div>
		</div>
		<div class="row cl" id="price1">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>抵扣金额：</label>
			<div class="formControls col-xs-8 col-sm-10">
				<input type="text" class="input-text" value="" placeholder="请输入价值" id="price" name="price">
			</div>
		</div>
        <div class="row cl" id="goods1" hidden>
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>赠送商品：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" value="" placeholder="请输入赠送内容" id="goods" name="goods">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>生效时间：</label>
            <div class="formControls col-xs-8 col-sm-10">
				<input type="text" name="begin_time" value="" onfocus="WdatePicker()" id="datemin" class="input-text Wdate">
            </div>
        </div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>失效时间：</label>
			<div class="formControls col-xs-8 col-sm-10">
				<input type="text" name="end_time" value="" onfocus="WdatePicker()" id="datemax" class="input-text Wdate">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="/static/admin/js/validate-methods.js"></script>
<script type="text/javascript" src="/static/admin/js/messages_zh.js"></script>
<script type="text/javascript" src="/static/admin/lib/My97DatePicker/WdatePicker.js"></script>
<!--/_footer /作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
    $('#is_platform').change(function () {
        var is_platform = $('#is_platform').val();
        if(is_platform == 1){
            $('#bid').val('0');
            $('#business').hide();
        }
        if(is_platform == 0){
            $('#business').show();
        }
    });
    $('#type_id').change(function () {
        var type_id = $('#type_id').val();
        if(type_id == 2){
            $('#price').val('0');
            $('#price1').hide();
            $('#goods1').show();
        }
        if(type_id == 1){
            $('#price1').show();
            $('#goods').val('0');
            $('#goods1').hide();
        }
    });
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	$("#form-add").validate({
		rules: {
            is_platform: {required: true},
            bid: {required: true},
            type_id: {required: true},
            datemin: {required: true},
            datemax: {required: true}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var options = {
				success: function (data) {
					if(data.code == 0){
						layer.msg(data.msg,{icon:1,time:1000});
						setInterval("closeWindow()",1000);
					}else{
						layer.msg(data.msg,{icon:5,time:1000});
					}
				}
			};
			$(form).ajaxSubmit(options);
		}
	});
});
function closeWindow() {
	var index = parent.layer.getFrameIndex(window.name);
	window.parent.location.reload();
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>